<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!doctype html>
<html>
<head>
<style type="text/css">
li{list-style: none;}
</style>
</head>
<body class="gray-bg">
<div class="container creditbody">
	 <div class="iboxtitle">
	 	<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;&nbsp;贷后业务>续保业务>客户保险明细</span>
     </div>
     <div class="buttonfixed" id="renewalDiv">
			<button type="button" class="btn dpbtn_blue btnaplly" onclick="saveCommit();">提交保单信息</button>
    </div>
    <div class="ibox-content ibox-con">
		<%@include file="/jsp/common_yw_with_loan_include.jsp"%>
		<%@include file="/jsp/baoDanLuRuContent.jsp"%>
		<form class="form-horizontal" id="commentFormB">
		<div class="business-man">保险信息</div>
         <div class="tche-padding">
         	<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
         		<tr>
         			<input type="hidden" id="id" name="id" value="${dhInsurance.id }" />
         			<input type="hidden" id="renewalId" name="renewalId" value="${dhInsurance.renewalId }">
					<td align="right">
						<label class="control-label np">保险年度：</label>
					</td>
					<td> 
						<mytag:selectTag map="${insurantYear }" id="year" name="year" selected="${dhInsurance.year }" others="class='select-control' required='required'"/>
					</td>	
					<td align="right" class="typeRenewalType">
						<label class="control-label np">新保/续保：</label>
					</td>
					<td class="typeRenewalType">
						<mytag:selectTag map="${insurantType }" id="typeRenewal" name="typeRenewal" selected="${dhInsurance.typeRenewal }" others="class='select-control' required='required'"/>
					</td>
				</tr>
			</table>			
			<div class="baoxian-infor">交强险</div>
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">	
				<tr>
					<input type="hidden" id="q_id" name="q_id" value="${dhInsuranceCompulsory.id }" />
					<td align="right">
						<label class="control-label np">保险公司：</label>
					</td>
					<td colspan="3">
						<mytag:selectTag map="${insuranceCompany }" id="q_companyInsurance" name="q_companyInsurance" selected="${dhInsuranceCompulsory.companyInsurance }" others="class='select-control' required='required'"/>
					</td>
				</tr>
				<tr>	
					<td align="right">
						<label class="control-label np">保单号：</label>
					</td>
					<td>
						<input class="form-control"  placeholder="保单号" type="text" id="q_noInsurance" name="q_noInsurance" value="${dhInsuranceCompulsory.noInsurance }"/>
					</td>
					<td align="right">
						<label class="control-label np">续保/交强险确认人：</label>
					</td>
					<td>
						<mytag:selectTag map="${insuranceEmployee }" id="q_operatorNext" name="q_operatorNext" selected="${dhInsuranceCompulsory.operatorNext }" others="class='select-control' required='required'"/>
					</td>
				</tr>
				<tr>		
					<td align="right">
						<label class="control-label np">交强险起始日：</label>
					</td>
					<td>
						<input class="smallicontm form-control" required="required" placeholder="交强险起始日(必填)" type="text" id="q_dateStart" name="q_dateStart" value="<fmt:formatDate value='${dhInsuranceCompulsory.dateStart}' pattern='yyyy-MM-dd'/>"/>
					</td>
					<td align="right">
						<label class="control-label np">交强险到期日：</label>
					</td>
					<td>
						<input class="form-control" required="required" placeholder="交强险到期日(必填)" type="text" id="q_dateEnd" name="q_dateEnd" readonly="readonly" value="<fmt:formatDate value='${dhInsuranceCompulsory.dateEnd}' pattern='yyyy-MM-dd'/>"/>
					</td>
				</tr>
				
				<tr>		
					<td align="right">
						<label class="control-label np">交强险：</label>
					</td>
					<td>
						<input class="form-control" type="text" id="q_costPerson" required="required" placeholder="交强险(必填)" name="q_costPerson" value='<fmt:formatNumber type="number" value="${dhInsuranceCompulsory.costPerson }" pattern="0.00" maxFractionDigits="2"/>' onkeyup="value=value.replace(/[^\-?\d.]/g,''); countQcostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countQcostTotal();"/>
					</td>
					<td align="right">
						<label class="control-label np">车船税：</label>
					</td>
					<td>
						<input class="form-control" type="text" id="q_costSpecial" required="required" placeholder="车船税(必填)"  name="q_costSpecial" value='<fmt:formatNumber type="number" value="${dhInsuranceCompulsory.costSpecial }" pattern="0.00" maxFractionDigits="2"/>' onkeyup="value=value.replace(/[^\-?\d.]/g,''); countQcostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countQcostTotal();"/>
					</td>
				</tr>
				
				<%-- <tr>	
					<td align="right">
						<label class="control-label np">交强险保当地：</label>
					</td>
					<td class="tabletd-checkbox">
						<label><input type="radio" name="q_isLocal" class="table-checkbox q_isLocal" value="0" <c:if test="${dhInsuranceCompulsory.isLocal == 0 }">checked</c:if> />否</label>
						<label><input type="radio" name="q_isLocal" class="table-checkbox q_isLocal" value="1" <c:if test="${dhInsuranceCompulsory.isLocal == 1 }">checked</c:if> />是</label>
					</td>
					<td align="right">
						<label class="control-label np">交强险退保：</label>
					</td>
					<td class="tabletd-checkbox">
						<label><input type="radio" name="q_isCacel" class="table-checkbox q_isCacel" value="0" <c:if test="${dhInsuranceCompulsory.isCacel == 0 }">checked</c:if> />否</label>
						<label><input type="radio" name="q_isCacel" class="table-checkbox q_isCacel" value="1" <c:if test="${dhInsuranceCompulsory.isCacel == 1 }">checked</c:if> />是</label>
					</td>
				</tr> --%>
				<tr>
					<td align="right">
						<label class="control-label np">交强险合计：</label>
					</td>
					<td>
						<input class="form-control" type="text" id="q_costTotal" readonly="readonly" value="0"/>
					</td>
					<td align="right">
						<label class="control-label np">投保方：</label>
					</td>
					<td><mytag:selectTag map="${insurant }" id="q_objectInsure" name="q_objectInsure" selected="${dhInsuranceCompulsory.objectInsure }" others="class='select-control' required='required'"/>
					</td>
				</tr>
				<tr>	
					<td align="right">
						<label class="control-label np">出单日期：</label>
					</td>
					<td>
						<input class="smallicontm form-control" required="required" placeholder="出单日期(必填)" type="text" id="q_dateEffect" name="q_dateEffect" onclick="laydate()" value='<fmt:formatDate value="${dhInsuranceCompulsory.dateEffect}" pattern="yyyy-MM-dd"/>'/>
					</td>
					
					<%-- <td align="right">
						<label class="control-label np">交强险确认人：</label>
					</td>
					<td>
						<input class="form-control" type="text" id="q_confirmor" name="q_confirmor" value="${dhInsuranceCompulsory.confirmor }"/>
					</td> --%>
					<td align="right">
						<label class="control-label np">确认时间：</label>
					</td>
					<td>
						<input class="smallicontm form-control" required="required" placeholder="确认时间(必填)" type="text" id="q_timeConfirm" name="q_timeConfirm" onclick="laydate()" value="<fmt:formatDate value='${dhInsuranceCompulsory.timeConfirm}' pattern='yyyy-MM-dd'/>"/>
					</td>
				</tr>
			</table>
			<div class="baoxian-infor">商业险</div>
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">	
				<tr>
					
					<td align="right">
						<label class="control-label np">保险公司：</label>
					</td>
					<td colspan="3">
						<mytag:selectTag map="${insuranceCompany }" id="companyInsurance" name="companyInsurance" selected="${dhInsurance.companyInsurance }" others="class='select-control' required='required'"/>
					</td>
				</tr>
				<tr>	
					<td align="right">
						<label class="control-label np">保单号：</label>
					</td>
					<td>
						<input class="form-control" required="required" placeholder="保单号(必填)" type="text" id="noInsurance" name="noInsurance" value="${dhInsurance.noInsurance }"/>
					</td>
				</tr>
				<tr>		
					<td align="right">
						<label class="control-label np">商业险起始日：</label>
					</td>
					<td>
						<input class="smallicontm form-control" required="required" placeholder="商业险起始日(必填)" type="text" id="dateStart" name="dateStart"value="<fmt:formatDate value='${dhInsurance.dateStart}' pattern='yyyy-MM-dd'/>"/>
					</td>
					<td align="right">
						<label class="control-label np">商业险到期日：</label>
					</td>
					<td>
						<input class="form-control" required="required" placeholder="商业险到期日(必填)" type="text" id="dateEnd" name="dateEnd" readonly="readonly" value="<fmt:formatDate value='${dhInsurance.dateEnd}' pattern='yyyy-MM-dd'/>"/>
					</td>
				</tr>
				<%-- <tr>
					<td align="right">
						<label class="control-label np">商业险保当地：</label>
					</td>
					<td class="tabletd-checkbox">
						<label><input type="radio" name="isLocal" class="table-checkbox isLocal" value="0" <c:if test="${dhInsurance.isLocal == 0 }">checked</c:if> />否</label>
						<label><input type="radio" name="isLocal" class="table-checkbox isLocal" value="1" <c:if test="${dhInsurance.isLocal == 1 }">checked</c:if> />是</label>
					</td>
					<td align="right">
						<label class="control-label np">商业险退保：</label>
					</td>
					<td class="tabletd-checkbox">
						<label><input type="radio" name="isCacel" class="table-checkbox isCacel" value="0" <c:if test="${dhInsurance.isCacel == 0 }">checked</c:if> />否</label>
						<label><input type="radio" name="isCacel" class="table-checkbox isCacel" value="1" <c:if test="${dhInsurance.isCacel == 1 }">checked</c:if> />是</label>
					</td>
				</tr> --%>
			</table>
			<table cellpadding="0" cellspacing="0" border="0" class="thead-table thead-tablee">
				<thead class="thead-a">
				    <tr>
				     <th></th>
				   	 <th>车辆损失险</th>
					 <th>全车盗抢险</th>
					 <th>玻璃单碎险</th>
					 <th>不计免赔险</th>
					 <th>第三者责任</th>
					 <th>自燃险</th>
					 <th>涉水险</th>
					 <th>车上人员险</th>
					 <th>第三方特约险</th>
				    </tr>
				</thead>
				<tbody class="tbody-a">
				    <tr>
				      <td class="paddin-np">保额</td>
				      <td><input class="tbody-control" type="text" id="limitLoss" name="limitLoss" value='<fmt:formatNumber type="number" value="${dhInsurance.limitLoss }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				      <td><input class="tbody-control" type="text" id="limitSteal" name="limitSteal" value='<fmt:formatNumber type="number" value="${dhInsurance.limitSteal }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				      <td><input class="tbody-control" type="text" id="limitGlass" name="limitGlass" value='<fmt:formatNumber type="number" value="${dhInsurance.limitGlass }" pattern="0.00" maxFractionDigits="2"/>'/></td>
				      <td><input class="tbody-control" type="text" id="limitAoad" name="limitAoad" value='<fmt:formatNumber type="number" value="${dhInsurance.limitAoad }" pattern="0.00" maxFractionDigits="2"/>'/></td>
				      <td><input class="tbody-control" type="text" id="limitThird" name="limitThird" value='<fmt:formatNumber type="number" value="${dhInsurance.limitThird }" pattern="0.00" maxFractionDigits="2"/>'/></td>
				      <td><input class="tbody-control" type="text" id="limitIgnition" name="limitIgnition" value='<fmt:formatNumber type="number" value="${dhInsurance.limitIgnition }" pattern="0.00" maxFractionDigits="2"/>'/></td>
				      <td><input class="tbody-control" type="text" id="limitWade" name="limitWade" value='<fmt:formatNumber type="number" value="${dhInsurance.limitWade }" pattern="0.00" maxFractionDigits="2"/>'/></td>
				      <td><input class="tbody-control" type="text" id="limitPerson" name="limitPerson" value='<fmt:formatNumber type="number" value="${dhInsurance.limitPerson }" pattern="0.00" maxFractionDigits="2"/>'/></td>
				      <td><input class="tbody-control" type="text" id="limitSpecial" name="limitSpecial" value='<fmt:formatNumber type="number" value="${dhInsurance.limitSpecial }" pattern="0.00" maxFractionDigits="2"/>'/></td>
				    </tr>
				    <tr>
				      <td class="paddin-np">保费</td>
				      <td><input class="tbody-control" type="text" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" id="costLoss" name="costLoss" value='<fmt:formatNumber type="number" value="${dhInsurance.costLoss }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				      <td><input class="tbody-control" type="text" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" id="costSteal" name="costSteal" value='<fmt:formatNumber type="number" value="${dhInsurance.costSteal }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				      <td><input class="tbody-control" type="text" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" id="costGlass" name="costGlass" value='<fmt:formatNumber type="number" value="${dhInsurance.costGlass }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				      <td><input class="tbody-control" type="text" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" id="costAoad" name="costAoad" value='<fmt:formatNumber type="number" value="${dhInsurance.costAoad }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				      <td><input class="tbody-control" type="text" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" id="costThird" name="costThird" value='<fmt:formatNumber type="number" value="${dhInsurance.costThird }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				      <td><input class="tbody-control" type="text" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" id="costIgnition" name="costIgnition" value='<fmt:formatNumber type="number" value="${dhInsurance.costIgnition }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				      <td><input class="tbody-control" type="text" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" id="costWade" name="costWade" value='<fmt:formatNumber type="number" value="${dhInsurance.costWade }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				      <td><input class="tbody-control" type="text" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" id="costPerson" name="costPerson" value='<fmt:formatNumber type="number" value="${dhInsurance.costPerson }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				      <td><input class="tbody-control" type="text" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countCostTotal();" id="costSpecial" name="costSpecial" value='<fmt:formatNumber type="number" value="${dhInsurance.costSpecial }" pattern="0.00" maxFractionDigits="2"/>' /></td>
				    </tr>
				 </tbody>
			</table>
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">	
				<tr>
					<td align="right">
						<label class="control-label np">商业险合计：</label>
					</td>
					<td>
						<input class="form-control" type="text" id="costTotal" readonly="readonly" value="0"/>
					</td>
					
					<td align="right">
						<label class="control-label np">续保/商业险确认人：</label>
					</td>
					<td>
						<mytag:selectTag map="${insuranceEmployee }" id="operatorNext" name="operatorNext" selected="${dhInsurance.operatorNext }" others="class='select-control' required='required'"/>
					</td>
				</tr>
				<tr>	
					<td align="right">
						<label class="control-label np">出单日期：</label>
					</td>
					<td>
						<input class="smallicontm form-control" required="required" placeholder="出单日期(必填)" type="text" id="dateEffect" name="dateEffect" onclick="laydate()" value="<fmt:formatDate value='${dhInsurance.dateEffect}' pattern='yyyy-MM-dd'/>"/>
					</td>
					<%-- <td align="right">
						<label class="control-label np">商业险确认人：</label>
					<td>
						<input class="form-control" type="text" id="confirmor" name="confirmor" value="${dhInsurance.confirmor }"/>
					</td> --%>
					<td align="right">
						<label class="control-label np">确认时间：</label>
					</td>
					<td>
						<input class="smallicontm form-control" required="required" placeholder="确认时间(必填)" type="text" id="timeConfirm" name="timeConfirm" onclick="laydate()" value="<fmt:formatDate value='${dhInsurance.timeConfirm}' pattern='yyyy-MM-dd'/>"/>
					</td>
				</tr>
			</table>
			<div class="baoxian-infor">返利</div>
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">	
				<tr>
					<td align="right">
						<label class="control-label np">交强险返利：</label>
					</td>
					<td>
						<input class="form-control" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countjq();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countjq();" type="text" id="q_amountRebate" name="q_amountRebate" value='<fmt:formatNumber type="number" value="${dhInsuranceCompulsory.amountRebate }" pattern="0.00" maxFractionDigits="2"/>'/>
					</td>
					
					<td align="right">
						<label class="control-label np">商业险返利：</label>
					</td>
					<td>
						<input class="form-control" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countjq();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countjq();" type="text" id="amountRebate" name="amountRebate" value='<fmt:formatNumber type="number" value="${dhInsurance.amountRebate }" pattern="0.00" maxFractionDigits="2"/>'/>
					</td>
					<td align="right">
						<label class="control-label np">合计返利：</label>
					</td>
					<td>
						<input class="form-control" readonly="readonly" type="text" id="amountRebateTotal" name="amountRebateTotal" value='<fmt:formatNumber type="number" value="${dhInsurance.amountRebateTotal }" pattern="0.00" maxFractionDigits="2"/>'/>
					</td>
				</tr>
				<tr>
					<td align="right">
						<label class="control-label np">交强险实收：</label>
					</td>
					<td>
						<input class="form-control" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countss();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countss();" type="text" id="q_amountReceived" name="q_amountReceived" value='<fmt:formatNumber type="number" value="${dhInsuranceCompulsory.amountReceived }" pattern="0.00" maxFractionDigits="2"/>'/>
					</td>
					
					<td align="right">
						<label class="control-label np">商业险实收：</label>
					</td>
					<td>
						<input class="form-control" onkeyup="value=value.replace(/[^\-?\d.]/g,''); countss();" onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countss();" type="text" id="amountReceived" name="amountReceived" value='<fmt:formatNumber type="number" value="${dhInsurance.amountReceived }" pattern="0.00" maxFractionDigits="2"/>'/>
					</td>
					<td align="right">
						<label class="control-label np">合计实收：</label>
					</td>
					<td>
						<input class="form-control" type="text" readonly="readonly" id="amountReceivedTotal" name="amountReceivedTotal" value='<fmt:formatNumber type="number" value="${dhInsurance.amountReceivedTotal }" pattern="0.00" maxFractionDigits="2"/>'/>
					</td>
				</tr>
				<tr>
					<td align="right" valign="top">
						<label class="control-label np">备注：</label>
					</td>
					<td colspan="5">
						<textarea id="remarks" rows="3" cols="remarks" class="form-control">${dhInsurance.remarks }</textarea>
					</td>
				</tr>
			</table>		
		</div>
		<div class="business-manwife">审核信息</div>
        <div class="padding-nono">
		    <table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
				 <tr>
					<td align="right">
						<label class="control-label np">审核人：</label>
					</td>
					<td> 
						<input  class="form-control" type="text" id="auditor" name="auditor" value="${dhInsurance.auditor }"/>
					</td>	
					<td align="right">
						<label class="control-label np">审核时间：</label>
					</td>
					<td>
						<input class="smallicontm form-control" required="required" placeholder="审核时间(必填)" type="text" id="timeAudit" name="timeAudit" onclick="laydate({istime:true,format:'YYYY-MM-DD hh:mm:ss'})" value="<fmt:formatDate value='${dhInsurance.timeAudit}' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
					</td>
				</tr>	
			</table>
		</div>
		<!-- 当前经办人 -->
	    <%@include file="/jsp/comm_current_person_include.jsp"%>
		</form>
	</div>
	
</div>
	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>
	<script type="text/javascript" src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
	<!-- custom js -->
    <script type="text/javascript" src="${basePath}/js/loanAfter/BDvalidate.js" charset="utf-8"></script>  
	<!-- jqGrid -->
	<script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>
	
    <script type="text/javascript">
    var qstartOption = '';
    var startOption = '';
    
    
    $(function(){	
        $("#commentFormB").validate({
            showErrors: function (errorMap, errorList) {
                
                $.each(errorList, function (i, v) {
                    layer.tips(v.message, v.element, { time: 1500 });
                    return false;
                });  
            },
            onfocusout: function(element) { $(element).valid(); },
            onkeyup:false,
        });
	});	
    
    jQuery(function($) {  
    	//外部js调用
		qstartOption = {
		  elem: '#q_dateStart', 
		  event: 'focus' ,
		  format: 'YYYY-MM-DD',
		  istime: false,
		  istoday: false,
		  choose: function(datas){
		     var date=new Date(datas);
	    	date.setFullYear(date.getFullYear()+1);
	    	date.setDate(date.getDate()-1);
	    	$('#q_dateEnd').val(date.format('yyyy-MM-dd'));
		  },
		  clear:function(){
			  $('#q_dateEnd').val('');
		  }
		};
	   	 
	   	laydate(qstartOption);
	   	
		startOption = {
		  elem: '#dateStart', 
		  event: 'focus' ,
		  format: 'YYYY-MM-DD',
		  istime: false,
		  istoday: false,
		  choose: function(datas){
		     var date=new Date(datas);
	    	date.setFullYear(date.getFullYear()+1);
	    	date.setDate(date.getDate()-1);
	    	$('#dateEnd').val(date.format('yyyy-MM-dd'));
		  },
		  clear:function(){
			  $('#dateEnd').val('');
		  }
		};
	   	 
	   	laydate(startOption);
	   	
    	var renewalId = $.getUrlData('insureListId');
    	$('#renewalId').val(renewalId);
    	countCostTotal();
    	countQcostTotal();
    	
    	yearChange();
    	$('#year').change(function(){
    		yearChange();
    	});
    });
	
    
    function countCostTotal(){
    	var costLoss = $('#costLoss').val();
    	var costLossNum = (!costLoss || costLoss == '') ? 0 : parseFloat(costLoss);
    	
    	var costSteal = $('#costSteal').val();
    	var costStealNum = (!costSteal || costSteal == '') ? 0 : parseFloat(costSteal);
    	
    	var costGlass = $('#costGlass').val();
    	var costGlassNum = (!costGlass || costGlass == '') ? 0 : parseFloat(costGlass);
    	
    	var costAoad = $('#costAoad').val();
    	var costAoadNum = (!costAoad || costAoad == '') ? 0 : parseFloat(costAoad);
    	
    	var costThird = $('#costThird').val();
    	var costThirdNum = (!costThird || costThird == '') ? 0 : parseFloat(costThird);
    	
    	var costIgnition = $('#costIgnition').val();
    	var costIgnitionNum = (!costIgnition || costIgnition == '') ? 0 : parseFloat(costIgnition);
    	
    	var costWade = $('#costWade').val();
    	var costWadeNum = (!costWade || costWade == '') ? 0 : parseFloat(costWade);
    	
    	var costPerson = $('#costPerson').val();
    	var costPersonNum = (!costPerson || costPerson == '') ? 0 : parseFloat(costPerson);
    	
    	var costSpecial = $('#costSpecial').val();
    	var costSpecialNum = (!costSpecial || costSpecial == '') ? 0 : parseFloat(costSpecial);
    	
    	$('#costTotal').val((costLossNum + costStealNum + costGlassNum  + costAoadNum + costThirdNum + costIgnitionNum + costWadeNum + costPersonNum + costSpecialNum).toFixed(2)); 
    }
    
	function countQcostTotal(){
		var q_costPerson = $('#q_costPerson').val();
    	var q_costPersonNum = (!q_costPerson || q_costPerson == '') ? 0 : parseFloat(q_costPerson);
    	
    	var q_costSpecial = $('#q_costSpecial').val();
    	var q_costSpecialNum = (!q_costSpecial || q_costSpecial == '') ? 0 : parseFloat(q_costSpecial);
    	
    	$('#q_costTotal').val((q_costPersonNum + q_costSpecialNum).toFixed(2));
    }
    
  //保存提交保险单
	function saveCommit(){
		var validstatus = $("#commentFormB").valid();
		if(!validstatus){
			layer.msg("有验证未通过，请仔细检查！", {icon: 5});
			return;
		}
		saveInsurance(function(){
			saveQInsurance();
		});
	}
	
    var countjq=function(){
	  var amountRebate=$("#amountRebate").val()==""?"0":$("#amountRebate").val();
	  var q_amountRebate=$("#q_amountRebate").val()==""?"0":$("#q_amountRebate").val();
	  $("#amountRebateTotal").val((parseFloat(amountRebate)+parseFloat(q_amountRebate)).toFixed(2));
    }
  
    var countss=function(){
	  var amountReceived=$("#amountReceived").val()==""?"0":$("#amountReceived").val();
	  var q_amountReceived=$("#q_amountReceived").val()==""?"0":$("#q_amountReceived").val();
	  $("#amountReceivedTotal").val((parseFloat(amountReceived)+parseFloat(q_amountReceived)).toFixed(2));
    }
    
   //保存提交保险单
   function saveInsurance(fn){
	   var data = {};
	    data.isRenewal = 0;
		data.busiId = $('#busiId').val();
		data.cusId = $('#customerId').val();
		data.id = $('#id').val();
		data.year = $('#year').val();
		data.renewalId = $('#renewalId').val();
		data.typeRenewal = $('#typeRenewal').val();
		data.companyInsurance = $('#companyInsurance').val();
		data.dateStart = $('#dateStart').val();
		data.dateEnd = $('#dateEnd').val();
		data.noInsurance = $('#noInsurance').val();
		/* data.isLocal = $(".isLocal:checked").val();
		data.isCacel = $(".isCacel:checked").val(); */
		data.dateEffect = $('#dateEffect').val();
		data.objectInsure = $('#objectInsure').val();
		
		data.limitLoss = $('#limitLoss').val();
		data.costLoss = $('#costLoss').val();
		data.limitSteal = $('#limitSteal').val();
		data.costSteal = $('#costSteal').val();
		data.limitGlass = $('#limitGlass').val();
		data.costGlass = $('#costGlass').val();
		data.limitAoad = $('#limitAoad').val();
		data.costAoad = $('#costAoad').val();
		data.limitThird = $('#limitThird').val();
		data.costThird = $('#costThird').val();
		data.limitIgnition = $('#limitIgnition').val();
		data.costIgnition = $('#costIgnition').val();
		data.limitWade = $('#limitWade').val();
		data.costWade = $('#costWade').val();
		data.limitPerson = $('#limitPerson').val();
		data.costPerson = $('#costPerson').val();
		data.limitSpecial = $('#limitSpecial').val();
		data.costSpecial = $('#costSpecial').val();
		data.amountRebate = $('#amountRebate').val();
		data.amountReceived = $('#amountReceived').val();
		data.amountRebateTotal = $('#amountRebateTotal').val();
		data.amountReceivedTotal = $('#amountReceivedTotal').val();
		data.operatorNext = $('#operatorNext').val();
		data.auditor = $('#auditor').val();
		data.timeAudit = $('#timeAudit').val();
		/* data.confirmor = $('#confirmor').val(); */
		data.timeConfirm = $('#timeConfirm').val();
		data.remarks = $('#remarks').val();
		
		$.dpAjax({
    		url:'${basePath}/DhInsuranceController/insurance',
    		data:data,
			success: function(datas){
			 	$('#id').val(datas.result);
			 	if(fn){
			 		fn();
			 	}
            }
	    });
   }
   
   //保存强险
   function saveQInsurance(){
	   var data = {};
		data.busiId = $('#busiId').val();
		data.cusId = $('#customerId').val();
		data.id = $('#q_id').val();
		data.insuranceId = $('#id').val();
		data.year = $('#year').val();
		data.typeRenewal = $('#typeRenewal').val();
		data.companyInsurance = $('#q_companyInsurance').val();
		data.dateStart = $('#q_dateStart').val();
		data.dateEnd = $('#q_dateEnd').val();
		data.noInsurance = $('#q_noInsurance').val();
		/* data.isLocal = $(".q_isLocal:checked").val();
		data.isCacel = $(".q_isCacel:checked").val(); */
		data.dateEffect = $('#q_dateEffect').val();
		data.objectInsure = $('#q_objectInsure').val();
		
		data.costPerson = $('#q_costPerson').val();
		data.costSpecial = $('#q_costSpecial').val();
		data.amountRebate = $('#q_amountRebate').val();
		data.amountReceived = $('#q_amountReceived').val();
		data.operatorNext = $('#q_operatorNext').val();
		data.auditor = $('#auditor').val();
		data.timeAudit = $('#timeAudit').val();
		/* data.confirmor = $('#q_confirmor').val(); */
		data.timeConfirm = $('#q_timeConfirm').val();
		data.insureListId=$.getUrlData("insureListId");
		layer.confirm('确认本次操作？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
			  btn: ['确定','取消'] //按钮
		}, function(){
			layer.closeAll();
			$.dpAjax({
		   		url:'${basePath}/DhInsuranceCompulsoryController/insurance',
		   		data:data,
				success: function(datas){
				 	$('#q_id').val(datas.result);
				 	layer.msg('保存提交成功', {icon: 6});
				 	setTimeout(function(){
				 		location.href='${basePath}/web/system/loanAfter/insureList.jsp'; 
				 	},1500)
	           }
		    });
		})	
  }
   //年度变化
   function yearChange(){
	   var year = $('#year').val();
	   
	    $('#companyInsurance').val("");
		$('#dateStart').val("");
		$('#dateEnd').val("");
		$('#noInsurance').val("");
		$('#dateEffect').val("");
		$('#objectInsure').val("");
		
		$('#limitLoss').val("");
		$('#costLoss').val("");
		$('#limitSteal').val("");
		$('#costSteal').val("");
		$('#limitGlass').val("");
		$('#costGlass').val("");
		$('#limitAoad').val("");
		$('#costAoad').val("");
		$('#limitThird').val("");
		$('#costThird').val("");
		$('#limitIgnition').val("");
		$('#costIgnition').val("");
		$('#limitWade').val("");
		$('#costWade').val("");
		$('#limitPerson').val("");
		$('#costPerson').val("");
		$('#limitSpecial').val("");
		$('#costSpecial').val("");
		$('#amountRebate').val("");
		$('#amountReceived').val("");
		$('#amountRebateTotal').val("");
		$('#amountReceivedTotal').val("");
		$('#operatorNext').val("");
		$('#auditor').val("");
		$('#timeAudit').val("");
		$('#timeConfirm').val("");
		$('#remarks').val("");
		$('#q_amountRebate').val("");
		$('#q_amountReceived').val("");
		$('#costTotal').val("");
		$('#q_dateEffect').val("");
		$('#q_timeConfirm').val("");
		$('#q_companyInsurance').val("");
		$('#q_dateStart').val("");
		$('#q_dateEnd').val("");
		$('#q_costPerson').val("");
		$('#q_costSpecial').val("");
		$('#q_costTotal').val("");
		$('#q_objectInsure').val("");
		$('#q_noInsurance').val("");
		$('#q_operatorNext').val("");
		
	   if(year == 1) {
		   $('.typeRenewalType').hide();
		   $('#typeRenewal').val('02');
	   } else {
		   $('.typeRenewalType').show();
	   }
   }
    </script>
</body>
</html>